package com.gg.douyin.sdk.service;

import com.gg.douyin.sdk.bean.DouyinConfigStorage;
import com.gg.douyin.sdk.bean.param.ClientToken;
import com.gg.douyin.sdk.bean.param.GetAccessToken;
import com.gg.douyin.sdk.bean.param.GetUserInfo;
import com.gg.douyin.sdk.bean.param.OauthConnect;
import com.gg.douyin.sdk.bean.param.RefreshToken;
import com.gg.douyin.sdk.bean.param.SendMessage;
import com.gg.douyin.sdk.bean.param.UploadMedia;
import com.gg.douyin.sdk.bean.param.VideoCommentList;
import com.gg.douyin.sdk.bean.param.VideoCommentReply;
import com.gg.douyin.sdk.bean.param.VideoData;
import com.gg.douyin.sdk.bean.param.VideoList;
import com.gg.douyin.sdk.bean.result.AccessTokenResult;
import com.gg.douyin.sdk.bean.result.BaseResult;
import com.gg.douyin.sdk.bean.result.ClientTokenResult;
import com.gg.douyin.sdk.bean.result.GetUserInfoResult;
import com.gg.douyin.sdk.bean.result.MediaUploadResult;
import com.gg.douyin.sdk.bean.result.VideoCommentListResult;
import com.gg.douyin.sdk.bean.result.VideoListResult;
import com.gg.douyin.sdk.exception.DouyinException;
import org.springframework.data.redis.core.RedisTemplate;

/**
 * 抖音接口调用统一service，实例化后需要调用init方法
 *
 * @author guiguan
 * @date 2019/12/10 9:09
 */
public interface DouyinService {

    String DOUYIN_API_PREFIX = "https://open.douyin.com";

    String OAUTH_CONNECT = "/platform/oauth/connect/";

    String GET_ACCESS_TOKEN = "/oauth/access_token/";

    String REFRESH_ACCESS_TOKEN = "/oauth/refresh_token/";

    String CLIENT_TOKEN = "/oauth/client_token/";

    String GET_USER_INFO = "/oauth/userinfo/";

    String VIDEO_LIST = "/video/list/";

    String VIDEO_DATA = "/video/data/";

    String VIDEO_COMMENT_LIST = "/video/comment/list/";

    String VIDEO_COMMENT_REPLY = "/video/comment/reply/";

    String IM_MESSAGE_SEND = "/im/message/send/";

    String MEDIA_UPLOAD = "/media/upload/";


    /**
     * 使用该service需要先初始化
     *
     * @param douyinConfigStorage DouyinConfigStorage
     */
    void init(DouyinConfigStorage douyinConfigStorage);

    /**
     * 获取二维码链接，用于扫码获取code
     *
     * @param oauthConnect OauthConnect
     */
    String getCode(OauthConnect oauthConnect);

    /**
     * 获取accessToken 15天过期
     *
     * @param getAccessToken GetAccessToken
     * @return AccessTokenResult
     */
    AccessTokenResult getAccessToken(GetAccessToken getAccessToken, RedisTemplate<String, String> redisTemplate) throws DouyinException;


    /**
     * 刷新accessToken 刷新后30天过期
     * 由于抖音获取评论，发送私信有限额，建议使用定时任务拉取,频率建议每天一次
     *
     * @param refreshToken RefreshToken
     * @return AccessTokenResult
     */
    AccessTokenResult refreshAccessToken(RefreshToken refreshToken) throws DouyinException;


    ClientTokenResult getClientToken(ClientToken clientToken) throws DouyinException;


    /**
     * 获取用户信息
     *
     * @param getUserInfo GetUserInfo
     * @return GetUserInfoResult
     * @throws DouyinException DouyinException
     */
    GetUserInfoResult userInfo(GetUserInfo getUserInfo) throws DouyinException;

    /**
     * 查询授权账号视频数据
     *
     * @param videoList VideoList
     * @return VideoListResult
     * @throws DouyinException DouyinException
     */
    VideoListResult videoList(VideoList videoList) throws DouyinException;

    /**
     * 查询指定视频数据
     *
     * @param videoData VideoData
     * @return VideoListResult
     * @throws DouyinException DouyinException
     */
    VideoListResult videoData(VideoData videoData) throws DouyinException;


    /**
     * 视频评论列表
     *
     * @param videoCommentList VideoCommentList
     * @return VideoCommentListResult
     * @throws DouyinException DouyinException
     */
    VideoCommentListResult videoCommentList(VideoCommentList videoCommentList) throws DouyinException;


    /**
     * 视频评论回复
     *
     * @param videoCommentReply VideoCommentReply
     * @return BaseResult
     * @throws DouyinException DouyinException
     */
    BaseResult videoCommentReply(VideoCommentReply videoCommentReply) throws DouyinException;

    /**
     * 消息发送
     *
     * @param sendMessage SendMessage
     * @return BaseResult
     * @throws DouyinException DouyinException
     */
    BaseResult messageSend(SendMessage sendMessage) throws DouyinException;

    /**
     * 上传文件
     * 开发者可通过本接口将使用素材上传至抖音服务器。个人上限为500
     * <p>
     * 去http://open.douyin.com/platform/business申请上传素材的能力
     * <p>
     * 必须申请的能力:
     * <p>
     * im 代用素材上传
     * <p>
     * 图片限制为5M bmp/gif/png/jpeg/jpg 长度<1500;宽度<1500
     * pdf限制为10M
     *
     * @param uploadMedia UploadMedia
     * @return MediaUploadResult
     * @throws DouyinException DouyinException
     */
    MediaUploadResult mediaUpload(UploadMedia uploadMedia) throws DouyinException;


}
